<!-- UserController.php-->
<?php 
	require 'VideoModel.php';
	require 'Controller.php';
	class VideoController extends Controller{
		function listvideos(){
			$model = new VideoModel();
			$data = $model->getVideoList();
			//转向用户列表页面
			include 'video/videolist.php';
		}

		function videoform(){
			//转向添加用户页面
			include 'video/videoform.php';
		}

		function videoedit(){
			$id = $_GET['id'];
			$model = new VideoModel();
			$result = $model->getUserByID($id);
			include 'video/videoedit.php';
		}

		function videoupdate(){
			$id = $_GET['id'];
			$model = new VideoModel();
			$result = $model->Updatevideo($id);
			if($result){
				echo '修改成功'.'<a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;index.php?c=video&m=listvideos = index.php?c=video&m=listvideos"); 	
			}else{
				echo '失败';
			}
		}

		function delvideo(){
			$id = $_GET['id'];
			$model = new Videomodel();
			$result = $model->Delvideo($id);
			if($result){
				echo '删除成功'.'<a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;index.php?c=video&m=listvideos = index.php?c=video&m=listvideos"); 
			}else{
				echo '删除失败';
			}
		}

		function addvideo(){
			//获取表单的数据
			//调用model中的addUser方法，添加到数据库中
			//var_dump($_POST);
			$data = $_POST;
			$model = new VideoModel();
			$result = $model->addVideo($data);
			//如果成功，输出，转到列表页面
			if($result){
				echo '添加成功'.'<a href="index.php?c=video&m=listvideos">如果没有跳转，请点这里跳转</a>';
				header("refresh:3;index.php?c=video&m=listvideos = index.php?c=video&m=listvideos"); 
			}else{
				echo '失败';
			}

		}
	}
 ?>